package com.jt.config;

import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
@ComponentScan("com.jt")
@PropertySource(value="classpath:/user.properties" , encoding="utf-8")
public class SpringConfig {
    @Value("${user.id}")//在Spring容器中查找key=user.id的数据
    Integer id;
    @Value("${user.username}")
    String username;
@Bean
    public User user() {
    User user = new User();
    user.setId(id);
    user.setName(username);
    return user;
}
}
